package com.siteseat.common.json;

import java.io.IOException;

import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.JsonSerializer;
import org.codehaus.jackson.map.SerializerProvider;

import com.siteseat.common.security.Permission;

public class PermissionSerializer extends JsonSerializer<Permission> {

  /**
   * {@inheritDoc}
   */
  @Override
  public void serialize( Permission value, JsonGenerator jgen, SerializerProvider provider ) throws IOException,
          JsonProcessingException {
    jgen.writeString( value.toString() );
  }

  /**
   * {@inheritDoc}
   */
  @Override
  public Class<Permission> handledType() {
    return Permission.class;
  }

}
